package com.example.neutonote2.data.dao;

import androidx.lifecycle.LiveData;
import androidx.room.*;
import com.example.neutonote2.data.model.Category;

import java.util.List;

/**
 * 分类数据访问对象
 */
@Dao
public interface CategoryDao {
    @Insert
    long insert(Category category);

    @Update
    void update(Category category);

    @Delete
    void delete(Category category);

    @Query("SELECT * FROM categories ORDER BY name ASC")
    LiveData<List<Category>> getAllCategories();

    @Query("SELECT * FROM categories WHERE id = :id")
    LiveData<Category> getCategoryById(int id);
    
    @Query("SELECT * FROM categories WHERE name = :name LIMIT 1")
    LiveData<Category> getCategoryByName(String name);
    
    @Query("SELECT * FROM categories WHERE isDefault = 1")
    LiveData<List<Category>> getDefaultCategories();
} 